import java.util.Random;
import java.util.Scanner;

public class NGuessNumber {

    int[] i = new int[]{};
    public int[] generateAnswer() {
        Random random = new Random();
        int[] e = new int[]{};
        for (;;){
            int a1 = random.nextInt(9);
            int a2 = random.nextInt(9);
            int a3 = random.nextInt(9);
            int a4 = random.nextInt(9);
            if (a1 != a2 && a1 != a3 && a1 != a4 && a2 != a3 && a2 != a4 && a3 != a4) {
                i = new int[]{a1 , a2 ,a3 ,a4};
                break;
            }
        }

        return e;
    }
    public int[] getPlayerInput(){
        int f[]= new int[]{};
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个数");
        int a1 =scanner.nextInt();
        System.out.println("请输入第二个数");
        int a2 = scanner.nextInt();
        System.out.println("请输入第三个数");
        int a3 = scanner.nextInt();
        System.out.println("请输入第四个数");
        int a4 = scanner.nextInt();
        f = new int []{a1,a2,a3,a4};
        return f;
    }

    public boolean compareGuessAnswer() {
        int e[] = generateAnswer();
        while (true) {
            for (; ; ) {
                int f[] = getPlayerInput();
                for (int i = 0; i < e.length - 1; i++) {
                    for (int j = f.length - 1; j >= 0; j--)
                        if (e[i] == f[j]) {
                            System.out.println("您输入的：" + f[j] + "是正确的");
                        }
                }
                int A = iswin(e, f);
                if (A == 4) {
                    System.out.println("true");
                    break;
                } else {
                    System.out.println("false");
                }
            }
        }
    }
    public int iswin( int e [], int f []){
        int A = 0;
        for (int i = 0; i < e.length-1; i++) {
            for (int j = f.length-1; j >= 0; j--) {
                if (e[i]==f[j]){
                    A++;
                }
            }
        }
        return A;
    }

    public static void main(String[] args) {
        NGuessNumber nGuessNumber = new NGuessNumber();
        nGuessNumber.compareGuessAnswer();
    }
}
